Telegram Group & Telegram Channel
Редирект вывода программы

В contextlib есть еще один прикольный контекстный менеджер — redirect_stdout, позволяющий перенаправить стандартный вывод программы.

Контекстный менеджер принимает аргумент, в котором мы можем указать, куда должен переправляться весь вывод в последующем блоке.

Таким образом, данные из print() в контекстом менеджере будут переправлены в открытый ранее файл, так как мы его передали в аргумент redirect_stdout.

Убедится в этом можем, открыв файл заново и прочитав оттуда данные.

#contextlib



tg-me.com/python_academy/562
Create:
Last Update:

Редирект вывода программы

В contextlib есть еще один прикольный контекстный менеджер — redirect_stdout, позволяющий перенаправить стандартный вывод программы.

Контекстный менеджер принимает аргумент, в котором мы можем указать, куда должен переправляться весь вывод в последующем блоке.

Таким образом, данные из print() в контекстом менеджере будут переправлены в открытый ранее файл, так как мы его передали в аргумент redirect_stdout.

Убедится в этом можем, открыв файл заново и прочитав оттуда данные.

#contextlib

BY Python Academy




Share with your friend now:
tg-me.com/python_academy/562

View MORE
Open in Telegram


Python Academy Telegram | DID YOU KNOW?

Date: |

Can I mute a Telegram group?

In recent times, Telegram has gained a lot of popularity because of the controversy over WhatsApp’s new privacy policy. In January 2021, Telegram was the most downloaded app worldwide and crossed 500 million monthly active users. And with so many active users on the app, people might get messages in bulk from a group or a channel that can be a little irritating. So to get rid of the same, you can mute groups, chats, and channels on Telegram just like WhatsApp. You can mute notifications for one hour, eight hours, or two days, or you can disable notifications forever.

Start with a fresh view of investing strategy. The combination of risks and fads this quarter looks to be topping. That means the future is ready to move in.Likely, there will not be a wholesale shift. Company actions will aim to benefit from economic growth, inflationary pressures and a return of market-determined interest rates. In turn, all of that should drive the stock market and investment returns higher.

Python Academy from cn


Telegram Python Academy
FROM USA